﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:cs="urn:cs">


  <msxsl:script language="C#" implements-prefix="cs">
    <![CDATA[
        public int SortRating(int iAll, int iSuccess)
        {
            if(iAll == 0)
            {
                return -1;
            }

            if(iSuccess == 0)
            {
                return 0;
            }

            double dRet1 = 100 * iSuccess / iAll;
            return (int)Math.Round(dRet1);
        }
        
        
        public string CalcRating(int iAll, int iSuccess)
        {
            if(iAll == 0)
            {
                return "-";
            }

            if(iSuccess == 0)
            {
                return "0 %";
            }

            double dRet1 = 100 * iSuccess / iAll;
            double dRet2 = Math.Round(dRet1);

            return dRet2.ToString() + " %";
        }
     ]]>
  </msxsl:script>






  <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
          h1 {
          color: green;
          font-family: Tahoma;
          font-size:16px;
          }

          table {
          font-family: Tahoma;
          font-size:12px;}

          td {
          padding-left:15px;
          padding-right:15px;
          padding-top:4px;
          padding-bottom:4px;
          }

          #left{
          float:left;
          width:40%;
          overflow:hidden;
          }

          #right{
          float:left;
          width:60%;
          overflow:hidden;
          }
        </style>
        <title>Ratings Summary</title>
      </head>
      <body>
        <xsl:call-template name="ReportData">
        </xsl:call-template>
      </body>
    </html>
  </xsl:template>
  <!--=============================================================================================================================================================-->
  <!-- Template to display all data                                                                                                                            -->
  <!--=============================================================================================================================================================-->
  <xsl:template name="ReportData">

    <hr></hr>
    <h1>
      <xsl:text>Summary: </xsl:text>
    </h1>

    <table>
      <tr>
        <th style="text-align: right;">Topics:</th>
        <td>
          <xsl:value-of select="//AliasRollupData/CountOfArticleAsAuthor" />
        </td>
      </tr>
      <tr>
        <th style="text-align: right;">CSAT Now:</th>
        <td>
          <xsl:value-of select="//AliasRollupData/CurrentMonthCSAT" />
        </td>
      </tr>
      <tr>
        <th style="text-align: right;">CSAT Old:</th>
        <td>
          <xsl:value-of select="//AliasRollupData/PrevMonthCSAT" />
        </td>
      </tr>
      <tr>
        <th style="text-align: right;">LiveFyre Unanswered:</th>
        <td>
          <xsl:value-of select="//AliasRollupData/LiveFyreUnansweredCount" />
        </td>
      </tr>
    </table>

    <hr></hr>

    <H1>
      <xsl:text>Verbatims: </xsl:text>
    </H1>

    <table>
      <tr>
        <th noWrap="" style="BORDER-TOP: ghostwhite 1px solid; HEIGHT: 20px; BORDER-BOTTOM: dimgray 1px solid; PADDING-BOTTOM: 5px; TEXT-ALIGN: center; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BACKGROUND-COLOR: gainsboro">
          No
        </th>
        <th noWrap="" style="BORDER-TOP: ghostwhite 1px solid; HEIGHT: 20px; BORDER-BOTTOM: dimgray 1px solid; PADDING-BOTTOM: 5px; TEXT-ALIGN: center; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BACKGROUND-COLOR: gainsboro">
          When
        </th>
        <th noWrap="" style="BORDER-TOP: ghostwhite 1px solid; HEIGHT: 20px; BORDER-BOTTOM: dimgray 1px solid; PADDING-BOTTOM: 5px; TEXT-ALIGN: center; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BACKGROUND-COLOR: gainsboro">
          What
        </th>
        <th noWrap="" style="BORDER-TOP: ghostwhite 1px solid; HEIGHT: 20px; BORDER-BOTTOM: dimgray 1px solid; PADDING-BOTTOM: 5px; TEXT-ALIGN: center; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BACKGROUND-COLOR: gainsboro">
          Topic
        </th>
        <th noWrap="" style="BORDER-TOP: ghostwhite 1px solid; HEIGHT: 20px; BORDER-BOTTOM: dimgray 1px solid; PADDING-BOTTOM: 5px; TEXT-ALIGN: center; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BACKGROUND-COLOR: gainsboro">
          Verbatim
        </th>
      </tr>
      <xsl:for-each select="//Verbatim">
        <xsl:sort select="Topic"/>

        <tr>

          <xsl:if test="(position() mod 2 = 0)">
            <xsl:attribute name="bgcolor">#EEEEFF</xsl:attribute>
          </xsl:if>

          <xsl:if test="hit1 != 1 or hit2 != 1">
            <xsl:attribute name="bgcolor">#FFCC99</xsl:attribute>
          </xsl:if>

          <td noWrap="" style="text-align: center;">
            <xsl:value-of select="position()" />
          </td>


          <td noWrap="" style="TEXT-ALIGN: center">
            <xsl:value-of select="When" />
          </td>

          <td style="TEXT-ALIGN: left">
            <xsl:value-of select="What" />
          </td>

          <td style="text-align: left;">
            <a>
              <xsl:attribute name="href">
                <xsl:value-of select="TopicUrl" />
              </xsl:attribute>
              <xsl:attribute name="target">
                <xsl:text disable-output-escaping="yes">_blank</xsl:text>
              </xsl:attribute>
              <xsl:value-of select="TopicName" />
            </a>
          </td>

          <td style="TEXT-ALIGN: left">
            <xsl:value-of select="Content" />
          </td>


        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet>
